/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.admin.controller;

import com.admin.model.EventLibraryFacadeLocal;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;

/**
 *
 * @author Tuan Long
 */
@Stateless
public class ShowEventEJB implements ShowEventEJBRemote {

    @EJB
    private EventLibraryFacadeLocal eventLibraryFacade;

    /**
     * @ShowEventEJB.fillEventsDataTable: return to List< -JSONObject String->,
     * with a JSONObject is the result from Select of database
     * @return List<>
     */
    @Override
    public List<String> fillEventsDataTable() {
        List<String> jsonlist = new ArrayList<String>();
        jsonlist = eventLibraryFacade.fillEventsDataTable();
        return jsonlist;
    }

    private void test_sp_testParameter() {
        List<String> list = eventLibraryFacade.testUseSPParameter("test");
        for (String eventLibraryJson : list) {
            System.out.println("Result: " + eventLibraryJson);
            System.out.println("-------------------------------");
        }
    }

    /**
     * @ShowEventEJB.fillRegisteredTable Desc: Get data from database, return
     * List<json-string>
     * @return List<>
     */
    @Override
    public List<String> fillRegisteredTable() {
        List<String> jsonlist = new ArrayList<String>();
        jsonlist = eventLibraryFacade.fillRegisteredTable();
        return jsonlist;
    }

    /**
     * @ShowEventEJB.fillTotalRegistered
     * @return List<>
     */
    @Override
    public List<String> fillTotalRegistered() {
        List<String> jsonlist = new ArrayList<String>();
        jsonlist = eventLibraryFacade.fillTotalRegistered();
        return jsonlist;
    }

    /**
     * @ShowEventEJB.fillTotalEventTypeTable
     * @return List<>
     */
    @Override
    public List<String> fillTotalEventTypeTable() {
        List<String> jsonlist = new ArrayList<String>();
        jsonlist = eventLibraryFacade.fillTotalEventTypeTable();
        return jsonlist;
    }

    /**
     * @param eventId integer
     * @return String JSONObject-String
     */
    @Override
    public String getEventContentById(int eventId) {                
        String json = eventLibraryFacade.getEventContentById(eventId);       
        return ""+json;
    }

    /**
     * @param eventId integer
     * @return String JSONObject-String
     */
    @Override
    public String getUpdateEventInformationById(int eventId) {
        return eventLibraryFacade.getUpdateEventInformationById(eventId);
    }

    /**
     * @param eventType String
     * @return List<String>
     */
    @Override
    public List<String> getTop10EventIdAndNameByEventTag(String eventType) {
        List<String> jsonlist = new ArrayList<String>();
        jsonlist = eventLibraryFacade.getTop10EventIdAndNameByEventTag(eventType);
        return jsonlist;
    }

    @Override
    public List<String> getTop10EventIdAndName() {
        List<String> jsonlist = new ArrayList<String>();
        jsonlist = eventLibraryFacade.getTop10EventIdAndName();
        return jsonlist;
    }

    @Override
    public List<String> getEventComming(int day) {
        List<String> jsonlist = new ArrayList<String>();
        jsonlist = eventLibraryFacade.getEventComming(day);
        return jsonlist;
    }
    

}
